package com.cy.air.postXml.view
{
	import com.cy.air.postXml.ApplicationFacade;
	import com.cy.air.postXml.view.components.RequestUrlView;
	
	import flash.events.Event;
	
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class RequestUrlMediator extends Mediator implements IMediator
	{
		public static const NAME:String="requestUrlMediator";
		
		public function RequestUrlMediator(view:RequestUrlView)
		{
			super(NAME,view);
			view.addEventListener(RequestUrlView.SET_REQUEST_RUL,onFocusOut);
		}
		
		private function onFocusOut(e:Event):void
		{
			sendNotification(ApplicationFacade.SET_REQUEST_URL,requestUrlView.requestUrl);
		}
		
		public function get requestUrlView():RequestUrlView{
			return viewComponent as RequestUrlView;
		}
		
		override public function listNotificationInterests():Array
		{
			return [ApplicationFacade.REQUEST_URL_READY];
		}
		
		override public function handleNotification(notification:INotification):void
		{
			requestUrlView.requestUrl=notification.getBody() as String;
		}
	}
}